﻿using System;
using System.Web;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using gms.security;

namespace gms.data {
	public class Campaign : IComparable {
#region Properties
		public int campaign_id { get; set; }
		public int player_id { get; set; }
		public int system_id { get; set; }
		public string name { get; set; }
		public string description { get; set; }
		public bool is_open { get; set; }
		public string join_password { get; set; }
		public string game_notes { get; set; }
		public string group_notes { get; set; }
#endregion
#region Constructors

#endregion
#region Additional Loads

#endregion
#region CRUD

#endregion
#region Utilities
		public int CompareTo(object obj) {
			/*
			Campaign comp = (Campaign)obj;

			if (gm.first_name != comp.gm.first_name) {
				return gm.first_name.CompareTo(comp.gm.first_name);
			}
			else {
				return name.CompareTo(comp.name);
			}
			*/

			return 0;
		}
		private void fill(DataSet values) {
			if (!Database.dataset_is_empty(values)) {
				for (int i = 0; i < values.Tables[0].Columns.Count; i++) {
					switch (values.Tables[0].Columns[i].ColumnName) {
						case "campaign_id": campaign_id = (int)values.Tables[0].Rows[0]["campaign_id"]; break;
						case "player_id": player_id = (int)values.Tables[0].Rows[0]["player_id"]; break;
						case "system_id": system_id = (int)values.Tables[0].Rows[0]["system_id"]; break;
						case "name": name = (string)values.Tables[0].Rows[0]["name"]; break;
						case "description": description = (values.Tables[0].Rows[0]["description"] != DBNull.Value) ? (string)values.Tables[0].Rows[0]["description"] : null; break;
						case "is_open": is_open = (bool)values.Tables[0].Rows[0]["is_open"]; break;
						case "join_password": join_password = (values.Tables[0].Rows[0]["join_password"] != DBNull.Value) ? (string)values.Tables[0].Rows[0]["join_password"] : null; break;
						case "game_notes": game_notes = (values.Tables[0].Rows[0]["game_notes"] != DBNull.Value) ? (string)values.Tables[0].Rows[0]["game_notes"] : null; break;
						case "group_notes": group_notes = (values.Tables[0].Rows[0]["group_notes"] != DBNull.Value) ? (string)values.Tables[0].Rows[0]["group_notes"] : null; break;
					}
				}
			}
		}
#endregion
	}
}